using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for RemotePost
/// </summary>
public class RemotePost
{
    private System.Collections.Specialized.NameValueCollection Inputs;

    public string Url = "";
    public string Method = "post";
    public string FormName = "form1";

    public void Add(string name, string value)
    {
        Inputs.Add(name, value);
    }

    public void Post()
    {
        if (HttpContext.Current.Request.QueryString["lang_code"] != null)
        {
            this.Add("lang_code", HttpContext.Current.Request.QueryString["lang_code"]);
        }
        else if (HttpContext.Current.Request["lang_code"] != null)
        {
            this.Add("lang_code", HttpContext.Current.Request["lang_code"]);
        }

        System.Web.HttpContext.Current.Response.Clear();
        System.Web.HttpContext.Current.Response.Write("<html><head>");
        System.Web.HttpContext.Current.Response.Write(String.Format("</head><body onload='document.{0}.submit()'>", FormName));
        System.Web.HttpContext.Current.Response.Write(String.Format("<form name='{0}' method='{1}' action='{2}' >", FormName, Method, Url));
        int i = 0;
        while (i < Inputs.Keys.Count)
        {
            System.Web.HttpContext.Current.Response.Write(String.Format("<input name='{0}' type='hidden' value='{1}'>", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
            i += 1;
        }
        System.Web.HttpContext.Current.Response.Write("</form>");
        System.Web.HttpContext.Current.Response.Write("</body></html>");
        System.Web.HttpContext.Current.Response.End();
    }

    public RemotePost()
    {
        Inputs = new System.Collections.Specialized.NameValueCollection();
        //
        // TODO: Add constructor logic here
        //
    }
}
